package untiring07.j2ee.basic.projectv10.dao;

import java.util.List;

import mybatis3.helper.Pv10SqlSessionFactory;

import org.apache.ibatis.session.SqlSession;

import untiring07.j2ee.basic.projectv10.model.ParamVO;
import untiring07.j2ee.basic.projectv5.model.BoardVO;

public class BoardDAO {
	
	private static int perpage = 20;
	public static List<BoardVO> listBoard(int startno, String ftype, String fkey){
		List<BoardVO> result = null;
		SqlSession sess = Pv10SqlSessionFactory.openSession();
		ParamVO pvo = new ParamVO();
		pvo.setStartno(startno);
		pvo.setPerpage(perpage);
		pvo.setFtype(ftype);
		pvo.setFkey(fkey);
		try{
			result = sess.selectList("BoardMapper.findlistSQL",pvo);
		}finally{
			sess.close();
		}return result;
	}
	
	public static int totalBoard(String ftype,String fkey){
		int result = -1;
		SqlSession sess = Pv10SqlSessionFactory.openSession();
		ParamVO pvo = new ParamVO();
		pvo.setPerpage(perpage);
		pvo.setFtype(ftype);
		pvo.setFkey(fkey);
		try{
			result = sess.selectOne("BoardMapper.totalSQL",pvo);
		}finally{
			sess.close();
		}return result;
	}
	public static BoardVO viewBoard(BoardVO b) {
		SqlSession sess = Pv10SqlSessionFactory.openSession();
		BoardVO result = new BoardVO();
		try {
			
			result = sess.selectOne("BoardMapper.viewSQL",b);
		
		} finally {
			sess.close();
		}
		return result;
	}
	
	
	
}
